#include <pcap.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/if_ether.h>
#include <netinet/ip.h>
 
/* Looking for private ips */
#define PRIVATE_IN_CLASSC(a)            ((((in_addr_t)(a)) & 0xFFFF0000) == 0xc0a80000)
#define PRIVATE_IN_CLASSB(a)            ((((in_addr_t)(a)) & 0xFFF00000) == 0xac100000)
#define PRIVATE_IN_CLASSA(a)            ((((in_addr_t)(a)) & 0x0F000000) == 0x0a000000)



int main(int argc, char **argv)
{
  
  u_int32_t ip ;
  struct in_addr test;
  inet_aton(argv[1],&test);
  ip = ntohl(test.s_addr);
  

  printf("address in hex : 0x%X\n",ip);



  if (IN_CLASSA(ip)) printf("class A\n") ;
  if (IN_CLASSB(ip)) printf("class B\n") ;
  if (IN_CLASSC(ip)) printf("class C\n") ;
  if (IN_CLASSD(ip)) printf("class D\n") ;

  //printf("Result in Hex - A - : 0x%X\n",(in_addr_t)(ip) & 0xa0000000);
  //printf("Result in Hex - C - : 0x%X\n",(in_addr_t)(ip) ^ 0xc0a80000);

  if (PRIVATE_IN_CLASSA(ip)) printf("PRIVADA CLASE A\n");
  if (PRIVATE_IN_CLASSB(ip)) printf("PRIVADA CLASE B\n"); 
  if (PRIVATE_IN_CLASSC(ip)) printf("PRIVADA CLASE C\n");
  //if (private_classc(ip)) printf("PRIVADA CLACE C\n");

}
